//
//  MyBusinsesLicenceTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/7/30.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "MyBusinsesLicenceTableViewCell.h"

@implementation MyBusinsesLicenceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.backgroundColor = SFM242;
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.img];
    [self.img addSubview:self.timeLabel];
    [self.img addSubview:self.registLabel];
}

-(void)sendMyLicenceModel:(MyLicenceModel *)model
{
    if ([model.fj isEqualToString:@""]) {
        self.img.backgroundColor = SFMRandColor;
    }else
    {
        WeakSelf;
        [self.img sd_setImageWithURL:[NSURL URLWithString:model.fj] placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
            weakSelf.img.image = image;
        }];
    }
    self.timeLabel.text = [NSString stringWithFormat:@"%@ 到期",model.licenseenddate];
    self.registLabel.text = [NSString stringWithFormat:@"注册号：%@",model.vcorplicensecode];
}

-(UIImageView *)img
{
    if (_img == nil) {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(20, 0, WIDTH - 40, 194)];
        _img.contentMode = UIViewContentModeScaleAspectFill;
        _img.layer.cornerRadius = 4;
        _img.clipsToBounds = YES;
    }
    return _img;
}

-(UILabel *)timeLabel
{
    if (_timeLabel == nil) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 140, WIDTH - 60, 22)];
        _timeLabel.font = font(16);
        _timeLabel.textColor = SFMWhiteColor;
        _timeLabel.textAlignment = NSTextAlignmentRight;
    }
    return _timeLabel;
}

-(UILabel *)registLabel
{
    if (_registLabel == nil) {
        _registLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 164, WIDTH - 60, 20)];
        _registLabel.font = font(12);
        _registLabel.textColor = SFMColor(255, 255, 255);
        _registLabel.textAlignment = NSTextAlignmentRight;
    }
    return _registLabel;
}

-(void)send
{
    self.img.backgroundColor = SFMRandColor;
    self.timeLabel.text = @"2018-08-29 到期";
    self.registLabel.text = @"注册号：10839278548729130765";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
